using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HostsEditor
{
    public partial class form_AddEdit : Form
    {
        System.Drawing.IconConverter iconConverter = new IconConverter();
        public form_AddEdit()
        {
            InitializeComponent();
            btn_Ok.DialogResult = DialogResult.OK;
            this.Icon = HostsEditor.Properties.Resources.addIcon;
            this.Text = "Add new host";
        }

        public form_AddEdit(Host host)
        {
            InitializeComponent();
            Text = "Edit host";
            tbox_Domaine.Text = host.HostName;
            tbox_IP.Text = host.IP;
            tbox_Comment.Text = host.Comment;
            cbox_Enable.Checked = host.Enabled;

            btn_Ok.DialogResult = DialogResult.OK;
            Icon = HostsEditor.Properties.Resources.editIcon;
            cbox_Copy.Visible = false;
            Height = 170;
        }

        private void btn_Ok_Click(object sender, EventArgs e)
        {
            try
            {
                Uri tempUri = new Uri(tbox_Domaine.Text);
                tbox_Domaine.Text = tempUri.Host;
            }
            catch { }
            Close();
        }
    }
}